import MyTable from "@/components/MyTable";
import useTable from "@/hooks/useTable";
import { useMemo } from "react";
import { getOrderPage } from "@/services/customer/customer";
import { getUerInfo } from "@/utils/info";
import dayjs from "dayjs";

export default () => {

  const { tableProps} = useTable(getOrderPage, {
    defaultFormValues: {
      account:getUerInfo().account
    },
  });
  const columns = useMemo(() => {
    return [
      {
        title: "房间号",
        dataIndex: "roomNum",
      },
      {
        title: "姓名",
        dataIndex:'name',
      },
      {
        title: "订单号",
        render:(r)=><>{r.orderNo}</>
      },
      {
        title: "预定办理入住时间",
        render:(r)=>dayjs(r.orderCheckinTime).format("YYYY-MM-DD"),
      },
      {
        title: "入住时间-退房时间",
        render:(r)=>`${dayjs(r.stayTime).format("YYYY-MM-DD")} - ${dayjs(r.checkoutTime).format("YYYY-MM-DD")}`
      },
      {
        title: "预定时间",
        dataIndex:'orderTime',
      },
    ];
  }, []);

  return (
    <>
      <MyTable
        rowKey={"orderNo"}
        columns={columns}
        {...tableProps}
      />
    </>
  );
};
